{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% load static django_bootstrap5 widget_tweaks ietf_filters person_filters textfilters tz %}
{% block title %}Interim Request Details{% endblock %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static 'ietf/css/select2.css' %}">
{% endblock %}
{% block content %}{% timezone meeting.tz %}
    {% origin %}
    <h1>Interim Meeting Request Details</h1>
    <dl class="row my-3">
        <dt class="col-sm-2">
            Group
        </dt>
        <dd class="col-sm-10">
            <a href="{{ group.about_url }}">{{ group.acronym }}</a>
        </dd>
        <dt class="col-sm-2">
            Requested by
        </dt>
        <dd class="col-sm-10">
            {% person_link requester %}
        </dd>
        <dt class="col-sm-2">
            Status
        </dt>
        <dd class="col-sm-10">
            {{ meeting_status.name }}
        </dd>
        <dt class="col-sm-2">
            City
        </dt>
        <dd class="col-sm-10">
            {{ meeting.city|default:"Online" }}
        </dd>
        <dt class="col-sm-2">
            Country
        </dt>
        <dd class="col-sm-10">
            {{ meeting.country|default:"Online" }}
        </dd>
        <dt class="col-sm-2">
            Timezone
        </dt>
        <dd class="col-sm-10">
            {{ meeting.time_zone }}
        </dd>
        {% for assignment in meeting_assignments %}
            {% if meeting_assignments|length > 1 %}
                <dt class="col-sm-2">
                    Session
                </dt>
                <dd class="col-sm-10">
                    {{ assignment.status.name }}
                </dd>
            {% endif %}
            <dt class="col-sm-2">
                Date
            </dt>
            <dd class="col-sm-10">
                {{ assignment.timeslot.time|date:"Y-m-d" }}
            </dd>
            <dt class="col-sm-2">
                Start time
            </dt>
            <dd class="col-sm-10">
                {{ assignment.timeslot.time|date:"H:i" }}
                {% if meeting.time_zone != 'UTC' %}
                    ({{ assignment.timeslot.time|utc|date:"H:i" }} UTC)
                {% endif %}
            </dd>
            <dt class="col-sm-2">
                Duration
            </dt>
            <dd class="col-sm-10">
                {{ assignment.session.requested_duration|format_timedelta }}
            </dd>
            <dt class="col-sm-2">
                Remote instructions
            </dt>
            <dd class="col-sm-10">
                {{ assignment.session.remote_instructions|linkify|linebreaksbr }}
            </dd>
            <dt class="col-sm-2">
                Additional info
            </dt>
            <dd class="col-sm-10">
                {{ assignment.session.agenda_note|default:"(None)" }}
            </dd>
            {% if meeting_assignments|length > 1 %}
                {% if can_edit and assignment.can_be_canceled %}
                    <dt class="col-sm-2">
                        Actions
                    </dt>
                    <dd class="col-sm-10">
                        <a class="btn btn-danger btn-sm"
                           href="{% url 'ietf.meeting.views.interim_request_session_cancel' sessionid=assignment.session.pk %}">
                            Cancel session
                        </a>
                    </dd>
                {% endif %}
            {% endif %}
        {% endfor %}
    </dl>
    {%  with meeting_status.slug as status_slug %}
        {% if can_approve and status_slug == 'apprw' %}
            <form method="post">
            {% csrf_token %}
        {% endif %}
        {% if can_edit %}
            <a class="btn btn-primary"
               href="{% url 'ietf.meeting.views.interim_request_edit' number=meeting.number %}">Edit</a>
        {% endif %}
        {% if can_approve and status_slug == 'apprw' %}
            <button class="btn btn-primary" type="submit" name="approve" value="approve">Approve</button>
            <button class="btn btn-primary" type="submit" name="disapprove" value="disapprove">Disapprove</button>
        {% endif %}
        {% if user|has_role:"Secretariat" and status_slug == 'scheda' %}
            <a class="btn btn-primary"
               href="{% url 'ietf.meeting.views.interim_send_announcement' number=meeting.number %}">
                Announce
            </a>
            <a class="btn btn-warning"
               href="{% url 'ietf.meeting.views.interim_skip_announcement' number=meeting.number %}">
                Skip announcement
            </a>
        {% endif %}
        {% if can_edit %}
            {% if status_slug == 'apprw' or status_slug == 'scheda' or status_slug == 'sched' %}
                <a class="btn btn-danger"
                   href="{% url 'ietf.meeting.views.interim_request_cancel' number=meeting.number %}">
                    Cancel meeting
                </a>
            {% endif %}
        {% endif %}
        {% if status_slug == "apprw" %}
            <a class="btn btn-secondary float-end"
               href="{% url 'ietf.meeting.views.interim_pending' %}">Back</a>
        {% elif status_slug == "scheda" %}
            <a class="btn btn-secondary float-end"
               href="{% url 'ietf.meeting.views.interim_announce' %}">Back</a>
        {% elif status_slug == "sched" %}
            <a class="btn btn-secondary float-end"
               href="{% url 'ietf.meeting.views.session_details' num=meeting.number acronym=meeting.session_set.first.group.acronym %}">
                Back
            </a>
        {% else %}
            <a class="btn btn-secondary float-end"
               href="{% url 'ietf.meeting.views.upcoming' %}">Back</a>
        {% endif %}
        {% if can_approve and status_slug == 'apprw' %}</form>{% endif %}
    {% endwith %}
{% endtimezone %}{% endblock %}
{% block js %}
    <script src="{% static 'ietf/js/select2.js' %}"></script>
    <script src="{% static 'ietf/js/meeting-interim-request.js' %}"></script>
{% endblock %}